package models

type Usertemp struct {
	Id   int    `orm:"column(id)"`
	Name string `orm:"column(name)"`
}

func (u *Usertemp) TableName() string {
	return "usertemp"
}

type User struct {
	Id      int      `orm:"column(id)"`
	Name    string   `orm:"column(name)"`
	Profile *Profile `orm:"rel(one)"`      // OneToOne relation
	Post    []*Post  `orm:"reverse(many)"` // 设置一对多的反向关系
}

func (u *User) TableName() string {
	return "t_user"
}

type Profile struct {
	Id   int
	Age  int16
	User *User `orm:"reverse(one)"` // 设置一对一反向关系(可选)
}

func (u *Profile) TableName() string {
	return "t_profile"
}

type Post struct {
	Id    int
	Title string
	User  *User  `orm:"rel(fk)"` //设置一对多关系
	Tags  []*Tag `orm:"rel(m2m)"`
}

func (u *Post) TableName() string {
	return "t_post"
}

type Tag struct {
	Id    int
	Name  string
	Posts []*Post `orm:"reverse(many)"` //设置多对多反向关系
}

func (u *Tag) TableName() string {
	return "t_tag"
}
